<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <script type="text/javascript">
        if ("${del}" != "") {
            alert("${del}");
        }
    </script>
    <link rel="stylesheet" href="/css/bootstrap.css"/>
    <link rel="stylesheet" href="/css/bright.css"/>
    <link rel="stylesheet" href="/css/addBook.css" />
    <script type="text/javascript" src="/js/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="/js/bootstrap.js"></script>
    <title></title>
</head>

<body>
<div id="brall">
    <div id="nav">
        <p>商品管理>商品列表</p>
    </div>
    <div id="condition" style="text-align: center">
        <form id="myform" action="/prod/mySplict.action" method="post">
            商品名称：<input name="pname" id="pname" value="${sessionScope.vo.pname}">&nbsp;&nbsp;&nbsp;
            商品类型：<select name="typeid" id="typeid">
            <option value="-1">请选择</option>
                <option  value="${pt.typeId}">
                        ${pt.typeName}
                </option>
        </select>&nbsp;&nbsp;&nbsp;
            价格：<input name="lprice" id="lprice" value="${sessionScope.vo.lprice}">-
            <input name="hprice" id="hprice" value="${sessionScope.vo.hprice}">
            <input type="submit" value="查询" />
        </form>
    </div>
    <br>
    <div id="table">

                <div id="top">
                    <a href="/admin/addproduct.html?page=${pb.pageNum}">
                            <!-- <input type="button" class="btn btn-warning" id="btn1" data-toggle="modal" data-target="#myModal"-->
                            <!--value="新增商品">-->

                        <input type="button" class="btn btn-warning" id="btn1"
                               value="新增商品">
                    </a>
                </div>
                <!--显示分页后的商品-->
                <div id="middle">
                    <table class="table table-bordered table-striped">
                        <tr>

                            <th>商品名</th>
                            <th>商品介绍</th>
                            <th>定价（元）</th>
                            <th>商品图片</th>
                            <th>商品数量</th>

                            <th>操作</th>
                        </tr>

                            <tr>
                                <td>${p.pName}</td>
                                <td>${p.pContent}</td>
                                <td>${p.pPrice}</td>
                                <td><img width="55px" height="45px"
                                         src="/image_big/${p.pImage}"></td>
                                <td>${p.pNumber}</td>
                                    <!--<td><a href="/admin/product?flag=delete&pid=${p.pId}" onclick="return confirm('确定删除吗？')">删除</a>-->
                                    <!--&nbsp;&nbsp;&nbsp;<a href="/admin/product?flag=one&pid=${p.pId}">修改</a></td>-->

                                <td>
                                    <button type="button" class="btn btn-info myupdate"
                                            onclick="one()">编辑
                                    </button>
                                    <button type="button" class="btn btn-warning" id="mydel"
                                            onclick="del()">删除
                                    </button>
                                </td>
                            </tr>
                    </table>

                    <!--分页栏-->
                    <div id="bottom">
                        <ul class="pagination">
                            <li>
                                <a href="#">[总共页${pb.pages}]/[当前${pb.pageNum}]</a>
                            </li>
                            <li>
                                <a href="/prod/split.action?page=1">首页</a>
                            </li>
                            <li>
                                <a href="/prod/split.action?page=${pb.prePage}">上一页</a>
                            </li>
                            <li>
                                <a href="/prod/split.action?page=${pb.nextPage}">下一页</a>
                            </li>
                            <li>
                                <a href="/prod/split.action?page=${pb.pages}">尾页</a>
                            </li>
                        </ul>
                    </div>
                </div>
            <div>
                <h2 style="width:1200px; text-align: center;color: orangered;margin-top: 100px">暂时没有符合条件的商品！</h2>
            </div>
    </c:choose>
            </div>


</div>

<!--编辑的模式对话框-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">新增商品</h4>
            </div>
            <div class="modal-body" id="addTD">
                <form action="/admin/product?flag=save" enctype="multipart/form-data" method="post" id="myform">
                    <table>
                        <tr>
                            <td class="one">商品名称</td>
                            <td><input type="text" name="pname" class="two" class="form-control"></td>
                        </tr>
                        <!--错误提示-->
                        <tr class="three">
                            <td class="four"></td>
                            <td><span id="pnameerr"></span></td>
                        </tr>
                        <tr>
                            <td class="one">商品介绍</td>
                            <td><input type="text" name="pcontent" class="two" class="form-control"></td>
                        </tr>
                        <!--错误提示-->
                        <tr class="three">
                            <td class="four"></td>
                            <td><span id="pcontenterr"></span></td>
                        </tr>
                        <tr>
                            <td class="one">定价</td>
                            <td><input type="number" name="pprice" class="two" class="form-control"></td>
                        </tr>
                        <!--错误提示-->
                        <tr class="three">
                            <td class="four"></td>
                            <td><span id="priceerr"></span></td>
                        </tr>

                        <tr>
                            <td class="one">图片介绍</td>
                            <td><input type="file" name="pimage" class="form-control"></td>
                        </tr>
                        <tr class="three">
                            <td class="four"></td>
                            <td><span></span></td>
                        </tr>

                        <tr>
                            <td class="one">总数量</td>
                            <td><input type="number" name="pnumber" class="two" class="form-control"></td>
                        </tr>
                        <!--错误提示-->
                        <tr class="three">
                            <td class="four"></td>
                            <td><span id="numerr"></span></td>
                        </tr>


                        <tr>
                            <td class="one">类别</td>
                            <td>
                                <select name="typeid" class="form-control">
                                        <option value="${type.typeId}">${type.typeName}</option>
                                </select>
                            </td>
                        </tr>
                        <!--错误提示-->
                        <tr class="three">
                            <td class="four"></td>
                            <td><span></span></td>
                        </tr>

                        <tr>
                            <td>
                                <input type="submit" class="btn btn-success" value="提交" class="btn btn-success">
                            </td>
                            <td>
                                <button type="button" class="btn btn-info" data-dismiss="modal">取消</button>
                            </td>
                        </tr>
                    </table>
                </form>

            </div>

        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>
</body>
<!--弹出新增模式对话框-->
<script type="text/javascript">
    $(function () {
        $(".btn-info").on("click", function () {
            //浏览不关，第二次打开时要清空
            $("#myModal").modal("hide");

        });
        //新增学生非空判断
        $(".btn-success").on("click", function () {
            $("#myModal").modal("hide");
        });
    });
</script>
<script type="text/javascript">
    function mysubmit() {
        $("#myform").submit();
    }
    function del(pid,ispage) {
        if (confirm("确定删除吗")) {
            location.href = "/prod/delete.action?pid="+pid+"&ispage="+ispage;
        }
    }

    function one(pid,ispage) {
        location.href = "/prod/one.action?pid="+pid+"&ispage="+ispage;
    }
</script>


</html>